<?php
/**
 * Created by PhpStorm.
 * User: pangaofeng
 * Date: 16/3/27
 * Time: 下午4:01
 * Do more things with the least amount of code!
 */

namespace GFPHP;


/**
 * 错误处理
 * Class GFPHPException
 * @package GFPHP
 */
class Exception extends \Exception
{
    protected $severity;

    /**
     * Exception constructor.
     * @param string $message
     * @param int $code
     * @param \Exception $severity
     * @param $filename
     * @param $lineno
     */
    public function __construct($message, $code, $severity, $filename, $lineno) {
        $this->message = $message;
        $this->code = $code;
        $this->severity = $severity;
        $this->file = $filename;
        $template_c_path = __ROOT__ . parseDir(Config::config('app_dir'), Config::cache('cache_dir'), Config::template('view_c_dir'),Config::template('view_name'));
        $this->line = $lineno;
        //让模板友好显示报错信息
        if(($path = str_replace($template_c_path,'',$filename))!=$filename){
            $template = str_replace('.php',Config::template('view_suffix'),$path);
            $this->message = '模板  '.$template.'  第'.$this->line.'行出现错误:'.$this->message;
            exit($this->message);
        }
    }

}